﻿Imports System.IO

Public Class ApplicationEdit
	Inherits System.Web.UI.Page

	Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		If GlobalApp.DataSourceEditOfficer IsNot Nothing Then
			Dim deOfficerInfo As New SS.DataEntity.Entity(Of Entity.OfficerInfoItem)
			Dim ls As New List(Of Entity.OfficerInfoItem)
			ls.Add(GlobalApp.DataSourceEditOfficer)

			deOfficerInfo.Fill(ls)

			Me.CrystalReportSource1.Report.FileName = Server.MapPath("~/CrystalReport.rpt")
			Me.CrystalReportSource1.ReportDocument.SetDataSource(deOfficerInfo.DataSource)

			Dim strm As Stream
			strm = Me.CrystalReportSource1.ReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)
			Dim intLength As Integer = Integer.Parse(strm.Length.ToString)
			Dim bytBuffer(intLength) As Byte
			strm.Read(bytBuffer, 0, intLength)
			strm.Flush()
			Response.ClearContent()
			Response.ClearHeaders()
			Response.Buffer = True
			Response.AddHeader("Content-Disposition", "inline; filename=rnw_application.pdf")
			Response.AddHeader("Content-Length", intLength.ToString)
			Response.ContentType = "application/pdf"
			Response.OutputStream.Write(bytBuffer, 0, intLength)
			Response.Flush()
			Response.Close()
			strm.Close()
			strm = Nothing
		End If

	End Sub

End Class